home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
internet
/
yam_i_dodatki
/
yamnet
/
test.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1990-03-17
|
4KB
|
118 lines
/* test rexxextra.library */
/*
trace all
*/
interpret getclip('Tracing')
call pragma('P',-1)
call addlib 'rexxextra.library',-20,-30,0
testa. = ''
testa.0 = d2c(7)||'Not OK';testa.1 = 'OK'
arg xx f .
if xx = '' then xx = 1
if f = '' then f = 'FRCS'
do ii = 1 to xx
if index(f,'F') > 0 then call testfparse
if index(f,'R') > 0 then call testreplace
if index(f,'C') > 0 then call testcparse
if index(f,'S') > 0 then call testsortwords
end
exit 0
testfparse:
cdir = 'Volume:Dir1/DIR2/d3'
tt = '.type'
nn = 'name'
test = fparse(cdir,nn,tt) == cdir'/name.type'
test = test & fparse(cdir,'//name',tt) == 'Volume:Dir1/name.type'
test = test & fparse(cdir,'/dir3/name',tt) == 'Volume:Dir1/DIR2/dir3/name.type'
test = test & fparse(cdir,'/name',tt) == 'Volume:Dir1/DIR2/name.type'
test = test & fparse(cdir,'dir4/name','Source:.type') == cdir'/dir4/name.type'
test = test & fparse(cdir,'dir4/name','','',',') == 'Volume:,Dir1/DIR2/d3/dir4/,name,'
test = test & fparse(cdir,nn,tt,'','V') == 'Volume:'
test = test & fparse(cdir,nn,tt,'','D') == 'Dir1/DIR2/d3/'
test = test & fparse(cdir,'name.type','','','T') == tt
say 'fparse()' testa.test
return
testreplace:
bb = 'b'
th = 'this old house is sold'
test = replace('a',bb,'12b34b5') == '12a34a5'
test = test & replace('ax',bb,'12b34b5') == '12ax34ax5'
test = test & replace('','asdf','123asdf456asdfasdf789') == '123456789'
test = test & replace('abc','ab','abcdeabab') == 'abccdeabcabc'
test = test & replace('new','old',th) == 'this new house is snew'
test = test & replace('','old',th) == 'this house is s'
say 'replace()' testa.test
return
testcparse: procedure expose testa.
args. = ''
a1 = 'ARGS.NEW="1";ARGS.REMAIN="file show remainder";ARGS.ERRCODE="1";'
command = "file new show remainder"
template = "NEW/S"
test = cparse(command,template,"ARGS") == a1
a1 = 'ARGS.NEW="1";ARGS.FILE.1="show";ARGS.FILE.2="remainder";' || ,
'ARGS.FILE.3="none";ARGS.FILE.0="3";ARGS.ERRCODE="0";'
command = "file new show remainder none"
template = "NEW/S,FILE/..."
test = test & cparse(command,template,"ARGS.") == a1
a1 = 'ARGS.NEW="1";ARGS.FILE="filearg";ARGS.REMAIN="show remainder";' || ,
'ARGS.ERRCODE="1";'
command = "file filearg new show remainder"
template = "NEW/S,FILE"
test = test & a1 == cparse(command,template,"args")
command = 'file "Quoted Arg" new ' || 'help "HELP arg" show remainder'
template = "NEW/S,FLAG2/S,SHOW/S,HELP/K,FILE"
a1 = cparse(command,template,"ARGS")
qwer. = ""
a2 = cparse(command,template,"qwer")
test = test & a1 == replace("ARGS.","QWER.",a2)
command = 'file "Quoted Arg" flag1 ' || 'help "HELP arg" show remainder'
a1 = 'Q.FLAG1="1";Q.FLAG2="0";Q.SHOW="1";Q.HELP="HELP arg";' || ,
'Q.FILE="Quoted Arg";Q.REMAIN="remainder";Q.ERRCODE="1";'
template = "FLAG1/S,FLAG2/S,SHOW/S,HELP/K,FILE"
test = test & cparse(command,template,"q") == a1
test = test & ,
Cparse('name volA:dirB/nameC quiet','QUIET/S,NAME/A','args') == ,
'ARGS.QUIET="1";ARGS.NAME="volA:dirB/nameC";ARGS.ERRCODE="0";'
test = test & ,
Cparse('quiet','QUIET/S,NAME/A','args') == ,
'ARGS.QUIET="1";ARGS.ERRTEXT="Required argument missing: NAME";ARGS.ERRCODE="2";'
say 'Cparse()' testa.test
return
testsortwords:
test = sortwords('refit point zoo asphalt bum') == ,
'asphalt bum point refit zoo'
test = test & sortwords(' this old house is sold ') == ,
'house is old sold this'
test = test & sortwords('every good boy deserves favor') == ,
'boy deserves every favor good'
test = test & sortwords('now is the time for all good men') == ,
'all for good is men now the time'
test = test & sortwords(' to come to the aid of their country ') == ,
'aid come country of the their to to'
test = test & sortwords('asphalt') == 'asphalt'
test = test & sortwords('') == ''
say 'sortwords()' testa.test
return